package compress;

import org.junit.Test;

import com.compress.Compressor;
import com.compress.CssCompressor;
import com.compress.FilePath;
import com.compress.JSCompressor;
import com.compress.MergeFile;
import com.compress.Mergeable;

public class Demo {
	/**
	 * 对css单个文件进行压缩
	 */
	@Test
	public void test1(){
		Compressor com = new CssCompressor();
		FilePath path = new FilePath("D:\\a\\sign\\src\\main\\webapp\\css\\nav.css","c:/Users/wangyiyin/Desktop/webapp");
		try {
			com.compress(path);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	/**
	 * 对css文件夹进行压缩
	 */
	@Test
	public void test2(){
		Compressor com = new CssCompressor();
		FilePath path = new FilePath("D:\\a\\sign\\src\\main\\webapp","c:/Users/wangyiyin/Desktop/webapp");
		try {
			com.compress(path);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	/**
	 * 将多个css文件合并压缩成一个文件
	 */
	@Test
	public void test3(){
		Mergeable merge = new CssCompressor();
		String[] excludes = {"comm/fonts/fontawesome-webfont.woff2", "comm/fonts/glyphicons-halflings-regular.woff2",
				"comm/css/style.all.min.css", "comm/css/style.all.css" };
		MergeFile file = new MergeFile("G:\\eclipse-workplace\\17Jobh5\\WebContent\\index副本.html","c:/Users/wangyiyin/Desktop/webapp",excludes);
		try {
			merge.merge(file);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	/**
	 * 对js单个文件进行压缩
	 */
	@Test
	public void test4(){
		Compressor com = new JSCompressor();
		FilePath path = new FilePath("D:\\a\\sign\\src\\main\\webapp\\js\\main.js","c:/Users/wangyiyin/Desktop/webapp");
		try {
			com.compress(path);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	/**
	 * 对js文件夹进行压缩
	 */
	@Test
	public void test5(){
		Compressor com = new JSCompressor();
		FilePath path = new FilePath("D:\\a\\sign\\src\\main\\webapp","c:/Users/wangyiyin/Desktop/webapp");
		try {
			com.compress(path);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	/**
	 * 将多个js文件合并压缩成一个文件
	 */
	@Test
	public void test6(){
		Mergeable merge = new JSCompressor();
		String[] excludes = {"comm/js/data.all.js", "comm/js/data.all.min.js" };
		MergeFile file = new MergeFile("G:\\eclipse-workplace\\17Jobh5\\WebContent\\index.html","c:/Users/wangyiyin/Desktop/webapp",excludes);
		try {
			merge.merge(file);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
